package cn.crm.system.service.impl;

import cn.crm.common.annotation.DataScope;
import cn.crm.common.exception.ServiceException;
import cn.crm.common.utils.SecurityUtils;
import cn.crm.common.utils.StringUtils;
import cn.crm.common.utils.bean.BeanValidators;
import cn.crm.system.domain.pojo.dto.BusinessDto;
import cn.crm.system.domain.pojo.dto.ContactsDto;
import cn.crm.system.domain.pojo.dto.UploadingDto;
import cn.crm.system.domain.pojo.entity.Business;
import cn.crm.system.domain.pojo.entity.BusinessAndContactsUpdate;
import cn.crm.system.domain.pojo.vo.BusinessVo;
import cn.crm.system.domain.pojo.vo.CaseVo;
import cn.crm.system.domain.pojo.vo.ContactsVo;
import cn.crm.system.domain.pojo.vo.UploadingVo;
import cn.crm.system.mapper.*;
import cn.crm.system.service.IBusinessService;
import cn.crm.system.service.IUploadingService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.validation.Validator;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;


/**
 * 处理上传模块的接口
 */

@Slf4j
@Service
public class UploadingServiceImpl implements IUploadingService {

    @Autowired
    private UploadingMapper uploadingMapper;

    /**
     * 上传资料
     * @param uploadingDto
     * @return
     */
    @Override
    public int insertUploading(UploadingDto uploadingDto) {
        log.debug("开始出来上传模块的业务");
        String createAccount = SecurityUtils.getUsername();
        uploadingDto.setCreateBy(createAccount);

            int i = uploadingMapper.insertUploading(uploadingDto);
            return i;
    }

    /**
     * 查询上传资料
     * @return
     */

    @Override
    @DataScope(deptAlias = "d")
    public List<UploadingVo> selectUploading(UploadingDto uploadingDto) {
        List<UploadingVo> uploadingVos = uploadingMapper.selectUploading(uploadingDto);
        return uploadingVos;
    }

    /**
     * 删除上传资料
     * @param id
     * @return
     */
    @Override
    public int deleteUploading(Long[] id) {
        int i = uploadingMapper.deleteUploading(id);
        return i;
    }
}

